package org.chenmin.gwt;

import com.axellience.vuegwt.core.client.Vue;
import com.axellience.vuegwt.core.client.VueGWT;
import com.google.gwt.core.client.EntryPoint;
import org.chenmin.gwt.pages.HelloComponentFactory;
import org.realityforge.gwt.appcache.client.ApplicationCache;
import org.realityforge.gwt.appcache.client.event.UpdateReadyEvent;

import javax.annotation.Nonnull;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class App implements EntryPoint {

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {

		final ApplicationCache cache = ApplicationCache.getApplicationCacheIfSupported();
		if ( null != cache ) {
            cache.addUpdateReadyHandler(new UpdateReadyEvent.Handler() {
                @Override
                public void onUpdateReadyEvent(@Nonnull final UpdateReadyEvent event) {
                    //Force a cache update if new version is available
                    cache.swapCache();
                }
            });
        }

//		VueGWT.init();
        VueGWT.initWithoutVueLib();
        Vue.attach("#app",HelloComponentFactory.get());
	}
}
